package com.zeus.springhibernate;

import org.activiti.engine.*;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2015/9/3.
 */
public class ActivitiService {
    private RepositoryService repositoryService;
    private RuntimeService runtimeService;
    private TaskService taskService;
    private FormService formService;
    private HistoryService historyService;
    private ManagementService managementService;
    private IdentityService identityService;

    public RepositoryService getRepositoryService() {
        return repositoryService;
    }

    public void setRepositoryService(RepositoryService repositoryService) {
        this.repositoryService = repositoryService;
    }

    public RuntimeService getRuntimeService() {
        return runtimeService;
    }

    public void setRuntimeService(RuntimeService runtimeService) {
        this.runtimeService = runtimeService;
    }

    public TaskService getTaskService() {
        return taskService;
    }

    public void setTaskService(TaskService taskService) {
        this.taskService = taskService;
    }

    public FormService getFormService() {
        return formService;
    }

    public void setFormService(FormService formService) {
        this.formService = formService;
    }

    public HistoryService getHistoryService() {
        return historyService;
    }

    public void setHistoryService(HistoryService historyService) {
        this.historyService = historyService;
    }

    public ManagementService getManagementService() {
        return managementService;
    }

    public void setManagementService(ManagementService managementService) {
        this.managementService = managementService;
    }

    public IdentityService getIdentityService() {
        return identityService;
    }

    public void setIdentityService(IdentityService identityService) {
        this.identityService = identityService;
    }

    /**
     * 返回所有的流程定义
     * @return
     */
    public List<ProcessDefinition> getAllProcessDefinition(){
        return repositoryService.createProcessDefinitionQuery().list();
    }

    /**
     * 查找个人任务
     * @param assignee
     * @return
     */
    public List<Task> getPersonalTask(String assignee){
        return taskService.createTaskQuery().taskAssignee(assignee).list();
    }

    public ProcessInstance startProcessByKey(String key,Map<String,Object> variables){
        return runtimeService.startProcessInstanceByKey(key,variables);
    }

}
